package com.ruoyi.project.hcy.administrations.service.Impl;

import com.ruoyi.project.hcy.administrations.domain.Approve;
import com.ruoyi.project.hcy.administrations.domain.Invite;
import com.ruoyi.project.hcy.administrations.mapper.ApproveMapper;
import com.ruoyi.project.hcy.administrations.mapper.InviteMapper;
import com.ruoyi.project.hcy.administrations.service.IInviteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName IInviteServiceImpl
 * @Author 金刚芭比
 * @Date 2020/9/17 14:53
 * @Version 1.0
 */
@Service
public class IInviteServiceImpl implements IInviteService {
    @Autowired
    private InviteMapper inviteMapper;

    @Autowired
    private ApproveMapper approveMapper;

    @Override
    public int insertInvite(Invite invite) {
        //设置默认值
        invite.setInviteType("招聘申请");
        invite.setInviteStatus("待审批..");
        int insert =  inviteMapper.insertInvite(invite);
        if (insert>0){
            Approve approve = new Approve();
            approve.setApproveName(invite.getInviteName());
            approve.setApproveTitle(invite.getInviteName()+"申请入职");
            approve.setApproveStatus(invite.getInviteStatus());
            approve.setApproveType(invite.getInviteType());
            approveMapper.insertApprove(approve);
        }
        return insert;
    }

    @Override
    public List<Invite> selectInviteAll(String inviteStatus) {
        return inviteMapper.selectInviteAll(inviteStatus);
    }

    @Override
    public int updateInviteStatus(Invite invite) {
        return inviteMapper.updateInviteStatus(invite);
    }

    @Override
    public Invite selectInviteByName(String inviteName) {
        return inviteMapper.selectInviteByName(inviteName);
    }
}
